<?php
/*
* @Created by Phpstorm
* @User: Zhangxinlei
* @Date: 
* @Time:
*/
declare (strict_types = 1);

namespace app\admin\controller;

use think\App;
use think\captcha\facade\Captcha;
use think\facade\Request;
use app\admin\controller\Base;
use app\common\service\AdminAdmin as S;
use think\facade\Session;

class Login extends Base
{
    public function index()
    {
        //是否已经登录
        if (S::isLogin()){

            return redirect(Request::root().'/index');
        }

        if (Request::isAjax()){

            $this->getJson(S::login(Request::param()));
        }
        return $this->fetch();
    }
    // 验证码
    public function verify(){
        ob_clean();
        return Captcha::create();
    }

    //退出登陆
    public function logout(){
        return $this->getJson(S::logout());
    }
}